﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyTruongHoc_App.MyControls
{
    public partial class ChonLop : Form
    {
        public delegate void EventUpdate(object sender, int _idLop);
        public event EventUpdate OkClicked;

        public ChonLop()
        {
            InitializeComponent();
        }

        private void ChonLop_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'qLTH.tbl_LopHoc' table. You can move, or remove it, as needed.
            tbl_LopHocTableAdapter.Connection.ConnectionString = PublicLib.getStrConn();
            this.tbl_LopHocTableAdapter.FillByFlag(this.qLTH.tbl_LopHoc, PConst.FLAG_NONE);
        }

        private void bt_ThemMoi_Click(object sender, EventArgs e)
        {
            int idLop = -1;
            if (cb_Lop.SelectedIndex != -1)
            {
                idLop = (int)cb_Lop.SelectedValue;
            }

            try
            {
                OkClicked(this, idLop);
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi :" + ex.Message);
            }

            this.Close();
        }
    }
}
